<template>
  <div class="warpper">
    <el-container>
      <el-header class="header" style="background: #373d41">
        <div class="logo-box">
          <img src="../assets/logo.png" style="width: 50px; height: 50px" />
          <div class="system-name">君旭景点管理系统平台</div>
        </div>
        <div class="userName">
          <el-dropdown>
            <div class="userName-box">
              <img src="../assets/user_avatar.jpg" style="width: 50px; height: 50px; object-fit: contain; border-radius: 50%" alt="" />
              <div style="font-size: 17px; color: #909399; margin-left: 10px">我已经不是我了</div>
              <i class="iconfont icon-daochu1024-17"></i>
            </div>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>修改密码</el-dropdown-item>
              <el-dropdown-item>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px" style="height: 100%; background: #333744">
          <el-menu router :default-active="activeMenu" unique-opened class="el-menu-vertical-demo" background-color="#333744" text-color="#fff" active-text-color="#409EFF">
            <div v-for="(item, index) in menuDataArr" :key="index">
              <el-submenu v-if="!item.isMenu" :index="index + ''">
                <template slot="title">
                  <i :class="item.icon"></i>
                  <span class="menu-font">{{ item.menuName }}</span>
                </template>
                <el-menu-item-group>
                  <div v-for="(list, id) in item.children" :key="id">
                    <el-menu-item class="menu-font" :index="list.path">{{ list.menuName }}</el-menu-item>
                  </div>
                </el-menu-item-group>
              </el-submenu>
              <el-menu-item v-else :index="item.path">
                <i :class="item.icon"></i>
                <span class="menu-font" slot="title">{{ item.menuName }}</span>
              </el-menu-item>
            </div>
          </el-menu>
        </el-aside>
        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeMenu: '/scenic_spot_mgr',
      //加菜单在这个数组里加，isMenu为flase代表有二级菜单，children二级菜单，
      menuDataArr: [
        {
          icon: 'iconfont icon-jingdian',
          menuName: '******',
          isMenu: false,
          children: [
            {
              menuName: '景点管理',
              isMenu: true,
              path: '/scenic_spot_mgr',
            },
            {
              menuName: '景点讲解',
              isMenu: true,
              path: '/scenic_explain_mgr',
            },
          ],
        },
        {
          icon: 'iconfont icon-yonghuguanli',
          menuName: '用户管理',
          isMenu: true,
          path: '/tourist',
        },
      ],
    }
  },
  created() {},
  methods: {
    selectMenu(val) {
      this.activeMenu = val
    },
  },
}
</script>

<style scope>
.menu-font {
  font-size: 16px;
}
.header {
  display: flex;
  padding: 0;
  justify-content: space-between;
}
.logo-box {
  width: 300px;
  height: 100%;
  margin-left: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.system-name {
  font-size: 22px;
  background-image: linear-gradient(135deg, red, blue);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.userName {
  width: 260px;
  height: 100%;
  display: flex;
  align-items: center;
}
.userName-box {
  padding: 4px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.userName-box:hover {
  background: #303133;
}
</style>
